package com.ruoyi.resume.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.resume.domain.request.LabelingRequest;
import com.ruoyi.resume.service.ExperienceLabelingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = "标签识别与存储")
@RestController
@RequestMapping("/experience-labeling")
public class ExperienceLabelingController {

    @Autowired
    private ExperienceLabelingService experienceLabelingService;

    /**
     * 生成在职状态标签
     * @param request 包含在职状态的对象
     * @return 在职状态标签键值对列表
     */
    @ApiOperation(value = "生成在职状态标签",
            notes = "通过传入在职状态列表，生成对应的在职状态标签")
    @PostMapping("/employment-status")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> employmentStatusLabeling(
            @ApiParam(value = "包含在职状态的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成在职状态标签
        List<Map<String, Integer>> result = experienceLabelingService.processEmploymentStatusRequest(request);

        // 返回标签键值对列表
        return ResponseEntity.ok(result);
    }

    /**
     * 生成工作经验标签
     * @param request 包含工作经验的对象
     * @return 工作经验标签键值对列表
     */
    @ApiOperation(value = "生成工作经验标签",
            notes = "通过传入工作经验列表，生成对应的工作经验标签")
    @PostMapping("/work-experience")
    @Anonymous
    public ResponseEntity<List<Map<String, Integer>>> workExperienceLabeling(
            @ApiParam(value = "包含工作经验的对象")
            @RequestBody LabelingRequest request) {

        // 调用服务层生成工作经验标签
        List<Map<String, Integer>> result = experienceLabelingService.processWorkExperienceRequest(request);

        // 返回标签键值对列表
        return ResponseEntity.ok(result);
    }
}
